// pages/collect/index.js
Page({

  data: {
    tabs: [
      {
        index: 0,
        value: "商品收藏",
        isActive: true
      },
      {
        index: 1,
        value: "品牌收藏",
        isActive: false
      },
      {
        index: 2,
        value: "店铺收藏",
        isActive: false
      },
      {
        index: 3,
        value: "交易记录",
        isActive: false
      }],
    type: 0,
    checkedClass: 'all',
    // 收藏夹的数据
    collection: []
  },
  onShow: function () {
    this.getCollection()
  },
  // 获取收藏夹数据
  getCollection () {
    const collection = wx.getStorageSync("collection")
    this.setData({
      collection
    })
  },
  // 点击tabs栏触发事件
  handleTabsTap (e) {
    const { index } = e.detail
    let tabs = this.data.tabs
    tabs.forEach(item => {
      if (item.index === index) {
        item.isActive = true
      }
      else {
        item.isActive = false
      }

    })
    this.setData({
      tabs
    })
  },
  // 选择分类
  classCheck (e) {
    // console.log(e.currentTarget.dataset.checked);
    this.setData({
      checkedClass: e.currentTarget.dataset.checked
    })
  }
})